package com.emptyMe.org.controller;

import com.emptyMe.basic.utils.AjaxResult;
import com.emptyMe.org.domain.User;
import com.emptyMe.org.query.LoginInfoQuery;
import com.emptyMe.org.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Api(tags = "用户接口",description = "用户接口详细api描述")
public class UserController {

    @Autowired
    private IUserService service;

    @GetMapping("/getCode")
    @ApiOperation(value = "获取所有员工")
    public AjaxResult getCode(String phone) {
        return service.getCode(phone);
    }

    @PostMapping("/registerByPhone")
    @ApiOperation(value = "通过手机号注册")
    public AjaxResult registerByPhone(@RequestBody LoginInfoQuery query){
        return service.registerByPhone(query);
    }

    @PostMapping("logout")
    @ApiOperation(value = "退出登录")
    public AjaxResult logout(){
        return service.logout();
    }

    @GetMapping("/getByUsername")
    public AjaxResult getById(String username) {
        return service.findByUsername(username);
    }
}
